<?php
class Ticket_data extends Data {
	private $alias = 'www-yueshihui-com';
	private $tb = 'ticket';
	private $cols = array('tid', 'product_id', 'name', 'original_price', 'market_price', 'real_price', 'num', 'last_num', 'status', 'description', 'start_time', 'end_time');

	/**
	 * 添加门票
	 * @param unknown_type $cols
	 */
	public function add($cols) {
		if(!($db = $this->connect($this->alias))) return false;

		if($db->insert($this->tb, $cols)) return $db->lastInsertId();
		else return false;
	}
	/**
	 * 获取票信息
	 * @param unknown_type $params
	 */
	public function info($params) {
		if(!($db = $this->connect($this->alias))) return false;

		$result = $db->one($this->tb, $this->cols, $params);
		return $result;
	}
	/**
	 * 获取票信息
	 * @param unknown_type $params
	 */
	public function ticketInfos($params) {
		if(!($db = $this->connect($this->alias))) return false;

		$result = $db->select($this->tb, $this->cols, $params);
		return $result;
	}
	/**
	 * 编辑门票信息
	 * @param unknown_type $id
	 * @param unknown_type $cols
	 */
	public function edit($params, $cols) {
		if(!($db = $this->connect($this->alias))) return false;
		
		return $db->update($this->tb, $cols, $params);
	}
	/**
	 * 删除
	 * @param unknown_type $params
	 */
	public function del($params) {
		if(!($db = $this->connect($this->alias))) return false;
		
		$cols = array('is_deleted' => 1);
		return $db->update($this->tb, $cols, $params);
	}
	/**
	 * 获取数量
	 * @param unknown_type $params
	 */
	public function count($params) {
		if(!($db = $this->connect($this->alias))) return false;
		
		return $db->count($this->tb, $params);
	}
	/**
	 * 分页获取角色信息
	 * @param unknown_type $page
	 * @param unknown_type $size
	 * @param unknown_type $params
	 * @param unknown_type $orderBy
	 */
	public function page($page, $size, $params = array(), $orderBy = '`id` DESC') {
		if(!($db = $this->connect($this->alias))) return false;
		
		return $db->page($this->tb, $this->cols, $params, $orderBy, $page, $size);
	}
}